@import './theme/default';
@import './theme/font';
@import './mixins/pointer-events';
$size: 16px;

.zent-checkbox-group {
  display: inline-block;
  font-size: 0;

  > :not(.zent-checkbox-wrap) {
    @include font-normal;
  }
}

.zent-checkbox-wrap {
  display: inline-block;
  cursor: pointer;
  font-size: 0;
  margin: 0;
  padding: 0;
  margin-right: 24px;
  vertical-align: middle;

  &.zent-checkbox-disabled {
    cursor: not-allowed;
  }

  &:last-child {
    margin-right: 0;
  }

  &:not(.zent-checkbox-disabled):hover {
    .zent-checkbox-inner {
      @include theme-color(border-color, primary, 4);
    }
  }
}

.zent-checkbox {
  position: relative;
  display: inline-block;
  width: $size;
  height: $size;
  white-space: nowrap;
  outline: none;
  vertical-align: middle;
  font-size: $font-size-normal;
  line-height: 1;
  margin: 0;
  padding: 0;

  & > input {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0;
    cursor: pointer;
  }

  &-label {
    @include font-normal;

    font-weight: $font-weight-normal;
    margin-left: 8px;
    display: inline-block;
    vertical-align: middle;
  }
}

.zent-checkbox-inner {
  @include theme-color(border-color, stroke, 4);
  @include theme-color(background-color, stroke, 9);
  position: relative;
  top: 0;
  left: 0;
  display: inline-block;
  width: $size;
  height: $size;
  border-radius: 2px;
  border-width: 1px;
  border-style: solid;
  box-sizing: border-box;
  transition: all 0.3s;

  &::after {
    box-sizing: content-box;
    position: absolute;
    display: block;
    content: ' ';
    font-size: 0;
    top: 3px;
    left: 2px;
    width: 10px;
    height: 8px;
    background-size: contain;
    transform: scale(0);
    transition: all 0.12s ease-in-out;
  }
}

.zent-checkbox-checked {
  & > .zent-checkbox {
    & > .zent-checkbox-inner {
      @include theme-color(border-color, primary, 4);
      @include theme-color(background-color, primary, 4);

      &::after {
        background-image: url('');
        transform: scale(1);
      }
    }
  }
}

.zent-checkbox-indeterminate {
  & > .zent-checkbox {
    & > .zent-checkbox-inner {
      @include theme-color(border-color, primary, 4);
      @include theme-color(background-color, stroke, 9);

      &::after {
        @include theme-color(background-color, primary, 4);
        top: 6px;
        left: 2px;
        width: 10px;
        height: 2px;
        border: 0;
        transform: rotate(0deg);
      }
    }
  }
}

.zent-checkbox-disabled {
  & > span {
    @include theme-color(color, stroke, 3);
  }

  & > .zent-checkbox {
    & > .zent-checkbox-inner {
      @include theme-color(background-color, stroke, 8);
      @include theme-color(border-color, stroke, 5);
    }

    & > input[type='checkbox'] {
      @include prevent-pointer-events;
    }
  }

  &.zent-checkbox-checked > .zent-checkbox {
    & > .zent-checkbox-inner {
      &:after {
        background-image: url('');
      }
    }
  }

  &.zent-checkbox-indeterminate > .zent-checkbox {
    & > .zent-checkbox-inner {
      &::after {
        @include theme-color(background-color, stroke, 5);
      }
    }
  }

  .zent-checkbox-label {
    @include theme-color(color, stroke, 4);
  }
}
